package com.example.basic.controller;

import com.example.basic.aop.OperationLogAnnotation;
import com.example.basic.domain.Log;
import com.example.basic.domain.User;
import com.example.basic.reslut.ResponseResult;
import com.example.basic.service.LogService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author mjw
 * @date 2023/6/7
 */
@Api(tags = "log的控制器")
@Slf4j
@RestController
@RequestMapping("/log")
public class LogController {

    @Autowired
    private LogService logService;

    @ApiOperation("分页获取log信息")
    @GetMapping("/query")
    public ResponseResult<PageInfo<Log>> getAll(@RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
                                                @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize) {
        PageInfo<Log> logList = logService.selectLog(pageNum, pageSize);
        return ResponseResult.success(logList);
    }

    @ApiOperation("获取全部的log信息")
    @GetMapping("/selectAll")
    public ResponseResult<List<Log>> getAll() {
        List<Log> logList = logService.selectAll();
        return ResponseResult.success(logList);
    }
}
